import CancelToken from '@prequest/cancel-token'

export default class SingletonCancelToken {
  source:any
  static instance:any

  constructor () {
    if (SingletonCancelToken.instance) {
      return SingletonCancelToken.instance
    }
    this.source = CancelToken.source()
    SingletonCancelToken.instance = this
    return SingletonCancelToken.instance
  }

  getSource () {
    return this.source
  }

  resetSource () {
    this.source = CancelToken.source()
  }
}
